package com.maxmlr.music.user.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.maxmlr.music.common.bean.ResultBean;
import com.maxmlr.music.common.bean.ResultPageBean;
import com.maxmlr.music.common.param.PageParam;
import com.maxmlr.music.user.param.UserSongEstimateInParam;
import com.maxmlr.music.user.param.UserSongEstimateOutParam;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;
import com.maxmlr.music.common.base.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import com.maxmlr.music.user.service.UserSongEstimateService;
import com.maxmlr.music.user.entity.UserSongEstimate;
import io.swagger.annotations.*;
import java.io.Serializable;

/**
 * @author max
 * @version 1.0
 * @ClassName UserSongEstimateController
 * @Description 用户歌曲评论信息表 控制器
 * @Copyright Copyright (c) 2020: www.maxmlr.com.
 * @since 2020-06-14
 */
@Slf4j
@RestController
@Api(value = "/user/user-song-estimate", tags = "UserSongEstimate 控制器")
@RequestMapping("/user/user-song-estimate")
public class UserSongEstimateController extends BaseController<UserSongEstimateService, UserSongEstimate> {

    @Autowired
    public UserSongEstimateService service;

    /**
     *
     * @param inParam
     * @param pageParam
     * @return
     */
    @GetMapping("/list-use")
    public ResultPageBean<UserSongEstimateOutParam> listUserSongEstimate(UserSongEstimateInParam inParam, PageParam pageParam) {
        Page<UserSongEstimateOutParam> page = getPage(pageParam);
        service.listUserSongEstimate(page, inParam);
        return ResultPageBean.ok(page);
    }

    /**
     * 保存
     *
     * @param dict
     * @return ResultBean<Boolean>
     */
    @RequiresPermissions("user:user-song-estimate:add" )
    @PostMapping
    public ResultBean<UserSongEstimateOutParam> save(UserSongEstimateInParam inParam) {
        return ResultBean.ok(service.saveEstimate(inParam));
    }


    /**
     * 修改
     *
     * @param dict
     * @return ResultBean<Boolean>
     */
    @PutMapping
    @RequiresPermissions("user:user-song-estimate:edit" )
    public ResultBean<Boolean> update(UserSongEstimate userSongEstimate) {
        return ResultBean.ok(service.updateById(userSongEstimate));
    }

    /**
     * 删除
     *
     * @param id
     * @return ResultBean<Boolean>
     */
    @DeleteMapping("/{id}" )
    @RequiresPermissions("user:user-song-estimate:remove" )
    public ResultBean<Boolean> remove(@PathVariable("id" ) Serializable id) {
        return ResultBean.ok(service.removeById(id));
    }

}
